package com.youkeda.comment.service;


import com.youkeda.comment.model.Result;
import com.youkeda.comment.model.User;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @InterfaceName UserService
 * @Author 刘正星
 * @Date 2020/7/16 13:26
 **/
public interface UserService {
    /**
     * 用户注册
     * @param userName
     * @param pwd
     * @return
     */
    public Result<User> register(String userName, String pwd);

    /**
     * 用户登录
     * @param userName
     * @param pwd
     * @return
     */
    public Result<User> login(String userName,String pwd);

    /**
     * 查询
     *
     * @return 全部User
     */
    // @Select("SELECT id,user_name as userName,pwd,nick_name as nickName,avatar,gmt_created as gmtCreated,gmt_modified as gmtModified FROM user")
    public List<User> findAll();

    /**插入
     * @param user
     * @return 行数
     */
    int add(User user);
    /*@Insert("INSERT INTO user (user_name, pwd, nick_name,avatar,gmt_created,gmt_modified) VALUES(#{userName}, #{pwd}, #{nickName}, #{avatar},now(),now())")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insert(UserDO userDO);
    */

    /**
     * 修改
     *
     * @param user
     * @return
     */
    // @Update("UPDATE user set nick_name = #{nickName},gmt_modified = now() where id = #{id} ")
    int update(User user);

    /**
     * 删除
     *
     * @param id
     * @return
     */
    //@Delete("delete from user where id=#{id}")
    int delete(long id);

    /**
     * 根据用户名查找
     *
     * @param name
     * @return userdo
     */
    //@Select("select id,user_name as userName,pwd,nick_name as nickName,avatar,gmt_created as gmtCreated,gmt_modified as gmtModified  from user  where user_name=#{userName} limit 1")
    User findByUserName( String name);

    List<User> query( String keyWord);


    List<User> search(String keyWord, LocalDateTime startTime, LocalDateTime endTime);

    int batchAdd(List<User> userDOs);

    List<User> findByIds(List<Long> ids);

}